package com.sentinel.controller;

import com.alibaba.csp.sentinel.Entry;
import com.alibaba.csp.sentinel.SphU;
import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @作者: 林江
 * @创建时间: 2023/12/11
 * @功能:
 */
@RestController
public class HelloWorldController {

    @GetMapping("/hello-01")
    @SentinelResource(value = "hello-01")
    public String test01() {
        return "hello-01";
    }

    @GetMapping("/hello-02")
    public String test02() {
        try (Entry entry = SphU.entry("hello-02")) {
            System.out.println("hello-02");
        } catch (BlockException e) {
            e.printStackTrace();
        }

        return "hello-02";
    }

    @GetMapping("/hello-03")
    public String test03() {
        return "hello-03";
    }
}
